﻿using TMOOC.CM.MobileShop.Util;
using System;
using TMOOC.CM.MobileShop.Business;
using Coldairarrow.Util;

namespace TMOOC.CM.MobileShop.Util
{
    public static partial class Extention
    {
        public static void InitEntity(this object entity)
        {
            var op = AutofacHelper.GetScopeService<IOperator>();

            if (entity.ContainsProperty("Id"))
                entity.SetPropertyValue("Id", IdHelper.GetId());
            if (entity.ContainsProperty("CreateTime"))
                entity.SetPropertyValue("CreateTime", DateTime.Now);
            if (entity.ContainsProperty("CreatorId"))
                entity.SetPropertyValue("CreatorId", op?.UserId);
            if (entity.ContainsProperty("Deleted"))
                entity.SetPropertyValue("Deleted", false);
        }
    }
}
